package com.wu.common.entity;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author whx
 * @date 2021/7/9
 */
@Data
@Accessors(chain = true)
public class ResultData<T> {

    private int state;
    private String message;
    private T data;

    public ResultData SUCCESS(T data){
        return new ResultData().setData(data)
                .setState(ResultDataEnum.SUCCESS.getState())
                .setMessage(ResultDataEnum.SUCCESS.getMessage());
    }

    public ResultData FAIL(String message){
        if(message != null && !"".equals(message)){
            return new ResultData().setState(ResultDataEnum.FAIL.getState())
                    .setMessage(message);
        }else{
            return new ResultData().setState(ResultDataEnum.FAIL.getState())
                    .setMessage(ResultDataEnum.FAIL.getMessage());
        }
    }

}
